package com.qf.commerce.controller;

import com.qf.commerce.entity.Commodity;
import com.qf.commerce.resp.ResponseResult;
import com.qf.commerce.service.CommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author peng
 * @Date 2023/9/12 11:45
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/commodity")
public class CommodityController {
    @Autowired
    private CommodityService commodityService;

//    添加一条商品数据
    @PostMapping("/addcommodity")
    public ResponseResult<Integer> addCommodity(@RequestBody Commodity commodity) {
        return ResponseResult.success(commodityService.addCommodity(commodity));
    }

    //    根据id删除多个商品
    @PutMapping("/updateByIdStatus")
    public ResponseResult<Integer> deleteCommodtiyById(@RequestBody List<Long> commodityId) {
        return ResponseResult.success(commodityService.deleteCommodtiyById(commodityId));
    }
}
